import React, { Component } from 'react';
import { connect } from 'dva';

let stateMapToProps = (state) => {
    return state
}

@connect(stateMapToProps)
class Login extends Component {
    render() {
        console.log(this.props)
        return (
            <div>
                <button onClick={this.login}>登录</button>
            </div>
        )
    }
     //登录
     login = async () => {
       
        let info = {
            user_name:'lixd',
            user_pwd:'Lixd123@'
        }
        await this.props.dispatch({  //调登录接口，异步
            type:'user/LOGIN',
            info
        })
        this.props.history.push('/main');
    }
}

export default  Login;


